<template>
  <el-dialog
    title="分配角色"
    :visible="showassignrole"
    width="30%"
    @close="closeAssign"
  >
    <el-checkbox-group v-model="checked">
      <el-checkbox v-for="item in selectList" :key="item.id" :label="item.id">
        {{ item.name }}
      </el-checkbox>
    </el-checkbox-group>

    <span slot="footer">
      <el-button @click="$emit('update:showassignrole', false)">
        取消
      </el-button>
      <el-button type="primary">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getRoleList } from '@/api/setting'
export default {
  props: {
    showassignrole: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      checked: [],
      selectList: []
    }
  },
  created () {
    this.getRoles()
  },
  methods: {
    async getRoles () {
      try {
        const res = await getRoleList({ page: 1, pagesize: 999 })
        this.selectList = res
        console.log(res)
        console.log(this.selectList)
      } catch (error) {
        console.log(error)
      }
    },
    closeAssign () {
      this.$emit('update:showassignrole', false)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
